﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _404park.ApplicationServices.Crawler.Parser.Provider;
using _404park.Core.Crawler;
using _404park.ApplicationServices.Crawler.Parser.Provider.RSS;

namespace _404park.ApplicationServices.Crawler.Parser
{
    public class FeedParserFactory
    {
        public IFeedParser GetParser(string providerName)
        {
            IFeedParser parser = null;

            if (providerName == null)
                providerName = "";

            if (providerName.Equals(PROVIDER.Youtube.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new YoutubeParser();
            else if (providerName.Equals(PROVIDER.Wikipedia.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new WikipediaParser();
            else if (providerName.Equals(PROVIDER.Flickr.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new FlickrParser();
            else if (providerName.Equals(PROVIDER.Ebay.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new EbayParser();
            else if (providerName.Equals(PROVIDER.Twitter.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new TwitterParser();
            else if (providerName.Equals(PROVIDER.BBC.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new BBCParser();
            else if (providerName.Equals(PROVIDER.ESPN.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new ESPNParser();
            else if (providerName.Equals(PROVIDER.Yahoo.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new YahooParser();
            else if (providerName.Equals(PROVIDER.CNN.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new CNNParser();
            else if (providerName.Equals(PROVIDER.HuffingtonPost.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new HuffingtonPostParser();
            else if (providerName.Equals(PROVIDER.TMZ.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new TMZParser();
            else if (providerName.Equals(PROVIDER.PeopleMagazine.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new PeopleMagazineParser();
            else if (providerName.Equals(PROVIDER._24h.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new _24hParser();
            else if (providerName.Equals(PROVIDER.BongDa.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new BongDaParser();
            else if (providerName.Equals(PROVIDER.CongAn.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new CongAnParser();
            else if (providerName.Equals(PROVIDER.DanTri.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new DanTriParser();
            else if (providerName.Equals(PROVIDER.HaiVl.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new HaiVlParser();
            else if (providerName.Equals(PROVIDER.NgoiSao.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new NgoiSaoParser();
            else if (providerName.Equals(PROVIDER.Sgtt.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new SgttParser();
            else if (providerName.Equals(PROVIDER.SoHoa.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new SoHoaParser();
            else if (providerName.Equals(PROVIDER.ThanhNien.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new ThanhNienParser();
            else if (providerName.Equals(PROVIDER.TTVH.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new TTVHParser();
            else if (providerName.Equals(PROVIDER.TuoiTre.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new TuoiTreParser();
            else if (providerName.Equals(PROVIDER.Vietnamnet.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new VietnamnetParser();
            else if (providerName.Equals(PROVIDER.VnExpress.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new VnExpressParser();
            else if (providerName.Equals(PROVIDER.GoogleCSE.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new GoogleCSEParser();
            else if (providerName.Equals(PROVIDER.Bing.ToString(), StringComparison.OrdinalIgnoreCase))
                parser = new BingParser();
            else
            {
                //Logger.LogError(new ApplicationException("Provider not found"), "Provider: " + providerName);
            }

            return parser;
        }
    }
}
